<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use app\common\middleware\LogMiddleware;
use think\facade\Route;

// 登录
Route::post('login', 'login/index');

// 不需要记录操作日志
Route::group(function () {
    // 个人模块
    Route::post('logout', 'login/logout');
    Route::put('modifyPwd', 'login/modifyPwd');
    Route::get('getInfo', 'login/getInfo');

    // 菜单模块
    Route::get('system/menu/list', 'system.SystemMenu/list');
    Route::get('system/menu/listAll', 'system.SystemMenu/listAll');
    Route::get('system/menu/:menuId$', 'system.SystemMenu/query');
    Route::get('system/menu/listAllActionByMenuId/:menuId$', 'system.SystemMenu/listAllActionByMenuId');

    // 角色模块
    Route::get('system/role/list', 'system.SysRole/list');
    Route::get('system/role/:roleId$', 'system.SysRole/query');

    // 角色菜单模块
    Route::get('system/role_menu/:roleId$', 'system.SysRoleMenu/query');

    //用户模块
    Route::get('system/sys_user/list', 'system.SysUser/list');
    Route::get('system/sys_user/:userId$', 'system.SysUser/query');

    // 字典类型模块
    Route::get('system/dict_type/list', 'system.SysDictType/list');
    Route::get('system/dict_type/:dictId$', 'system.SysDictType/query');

    // 字典数据模块
    Route::get('system/dict_data/list', 'system.SysDictData/list');
    Route::get('system/dict_data/:dictDataId$', 'system.SysDictData/query');
    Route::get('system/dict_data/type/:dictType$', 'system.SysDictData/queryByType');

    // 参数设置模块
    Route::get('system/sys_config/list', 'system.SysConfig/list');
    Route::get('system/sys_config/listByConfigKey', 'system.SysConfig/listByConfigKey');
    Route::get('system/sys_config/:sysConfigId$', 'system.SysConfig/query');

    // 系统公告模块
    Route::get('system/sys_notice/list', 'system.SysNotice/list');
    Route::get('system/sys_notice/:noticeId$', 'system.SysNotice/query');

    // 日志模块
    Route::get('system/sys_login_log/list', 'system.SysLoginLog/list');
    Route::get('system/sys_oper_log/list', 'system.SysOperLog/list');
    Route::get('system/sys_oper_log/:operId$', 'system.SysOperLog/query');

    // 文件模块
    Route::get('system/sys_file_cate/list', 'system.SysFileCate/list');
    Route::get('system/sys_file_cate/:id$', 'system.SysFileCate/query');
    Route::get('system/sys_file/list', 'system.SysFile/list');
    Route::get('system/sys_file/:id$','system.SysFile/query');
    Route::post('upload', 'common/upload');
});

// 需要记录操作日志
Route::group(function () {
    // 菜单模块
    Route::post('system/menu/insert', 'system.SystemMenu/insert');
    Route::delete('system/menu/delete/:menuId$', 'system.SystemMenu/delete');
    Route::put('system/menu/update', 'system.SystemMenu/update');

    // 角色模块
    Route::post('system/role/insert', 'system.SysRole/insert');
    Route::delete('system/role/delete/:roleId', 'system.SysRole/delete');
    Route::put('system/role/update', 'system.SysRole/update');

    // 角色菜单模块
    Route::post('system/role_menu/insert', 'system.SysRoleMenu/insert');
    Route::put('system/role_menu/update', 'system.SysRoleMenu/update');

    // 用户模块
    Route::post('system/sys_user/insert', 'system.SysUser/insert');
    Route::delete('system/sys_user/delete/:userId$', 'system.SysUser/delete');
    Route::put('system/sys_user/update', 'system.SysUser/update');
    Route::put('system/sys_user/changeStatus', 'system.SysUser/changeStatus');
    Route::put('system/sys_user/resetPwd', 'system.SysUser/resetPwd');

    // 字典类型模块
    Route::post('system/dict_type/insert', 'system.SysDictType/insert');
    Route::delete('system/dict_type/delete/:dictId$', 'system.SysDictType/delete');
    Route::put('system/dict_type/update', 'system.SysDictType/update');

    // 字典数据模块
    Route::post('system/dict_data/insert', 'system.SysDictData/insert');
    Route::delete('system/dict_data/delete/:dictDataId$', 'system.SysDictData/delete');
    Route::put('system/dict_data/update', 'system.SysDictData/update');

    // 参数设置模块
    Route::post('system/sys_config/insert', 'system.SysConfig/insert');
    Route::delete('system/sys_config/delete/:sysConfigId$', 'system.SysConfig/delete');
    Route::put('system/sys_config/update', 'system.SysConfig/update');

    // 系统公告模块
    Route::post('system/sys_notice/insert', 'system.SysNotice/insert');
    Route::delete('system/sys_notice/delete/:noticeId$', 'system.SysNotice/delete');
    Route::put('system/sys_notice/update', 'system.SysNotice/update');

    // 系统日志模块
    Route::delete('system/sys_login_log/delete/:logIds$', 'system.SysLoginLog/delete')
        ->pattern(['logIds' => '\d+(?:,\d+)*']);
    Route::delete('system/sys_login_log/clear', 'system.SysLoginLog/clear');
    Route::delete('system/sys_oper_log/delete/:operIds$', 'system.SysOperLog/delete')
        ->pattern(['logIds' => '\d+(?:,\d+)*']);
    Route::delete('system/sys_oper_log/clear', 'system.SysOperLog/clear');

    // 文件模块
    Route::post('system/sys_file_cate/insert', 'system.SysFileCate/insert');
    Route::put('system/sys_file_cate/update', 'system.SysFileCate/update');
    Route::delete('system/sys_file_cate/delete/:id$', 'system.SysFileCate/delete');
    Route::put('system/sys_file/rename','system.SysFile/rename');
    Route::put('system/sys_file/move/:ids', 'system.SysFile/move')
        ->pattern(['ids' => '\d+(?:,\d+)*']);
    Route::delete('system/sys_file/delete/:ids', 'system.SysFile/delete')
        ->pattern(['ids' => '\d+(?:,\d+)*']);
})->middleware([LogMiddleware::class]);